home *** CD-ROM | disk | FTP | other *** search
- /* © 1988, Bowers Development Corp. */
- /* WindowAids.c */
-
- #include "WindowAids.h"
-
-
- /*----------*/
- ListHandle NewV1List (bounds, parentWindow)
- Rect bounds;
- WindowPtr parentWindow;
- {
- Rect listBounds;
- Rect dataBounds;
- Point cSize;
- ListHandle list;
-
- listBounds = bounds;
- listBounds.right = listBounds.right - 15; /*for scroll bar*/
- SetRect (&dataBounds, 0, 0, 1, 0); /*one column, no rows*/
- SetPt (&cSize, listBounds.right - listBounds.left, 0);
- list = LNew (&listBounds, /*dialog item's box*/
- &dataBounds, /*one column, no rows*/
- cSize, /*cell size: full width, standard height*/
- 0, /*procid - standard text list*/
- parentWindow, /*parent window*/
- true, /*draw it*/
- false, /*has no grow*/
- false, /*no horizontal scroll*/
- true); /*vertical scroll*/
- (**list).selFlags = lOnlyOne + lNoNilHilite;
- return (list);
- } /*NewV1List*/
-
- /*----------*/
- void TextIDBox (textID, bounds)
- short textID;
- Rect bounds;
- {
- Handle text;
-
- text = GetResource ('TEXT', textID);
- if (text != nil) {
- LoadResource (text);
- HLock (text);
- TextBox (&(**text), GetHandleSize (text), &bounds, teJustLeft);
- HUnlock (text);
- }
- } /*TextIDBox*/
-
- /*----------*/
- void PlotIconID (iconID, bounds)
- short iconID;
- Rect bounds;
- {
- Handle icon;
-
- icon = GetIcon (iconID);
- if (icon != nil) {
- LoadResource (icon);
- PlotIcon (&bounds, icon);
- }
- } /*PlotIconID*/
-
- /*----------*/
- void DrawPictureID (pictID, bounds)
- short pictID;
- Rect bounds;
- {
- PicHandle pict;
-
- pict = GetPicture (pictID);
- if (pict != nil) {
- LoadResource ((Handle) (pict));
- DrawPicture (pict, &bounds);
- }
- } /*DrawPictureID*/
-
- /*----------*/
- void DrawGrayLine (bounds)
- Rect bounds;
- {
- PenState savePen;
-
- GetPenState (&savePen);
- PenNormal ();
- PenPat (gray);
- MoveTo (bounds.left, bounds.top);
- LineTo (bounds.right - 1, bounds.bottom - 1);
- SetPenState (&savePen);
- } /*DrawGrayLine*/
-
- /*----------*/
- void UpdatePopup (bounds, menuID, choice)
- Rect bounds;
- short menuID;
- short choice;
- {
- MenuHandle menu;
- Str255 menuItem;
-
- menu = (MenuHandle) (GetResource ('MENU', menuID));
- if (menu != nil) {
- GetItem (menu, choice, menuItem);
- bounds.left = bounds.left + 12;
- TextBox (&menuItem [1], menuItem [0], &bounds, teJustLeft);
- bounds.left = bounds.left - 12;
- }
- bounds.right = bounds.right - 1;
- bounds.bottom = bounds.bottom - 1;
- FrameRect (&bounds);
- MoveTo (bounds.right, bounds.top + 2);
- LineTo (bounds.right, bounds.bottom);
- LineTo (bounds.left + 2, bounds.bottom);
- } /*UpdatePopup*/
-
- /*----------*/
- void TrackPopup (bounds, menuID, choice)
- Rect bounds;
- short menuID;
- short *choice;
- {
- MenuHandle menu;
- Point corner;
- long result;
-
- menu = (MenuHandle) (GetResource ('MENU', menuID));
- if (menu != nil) {
- InsertMenu (menu, -1);
- corner = topLeft (bounds);
- LocalToGlobal (&corner);
- CheckItem (menu, *choice, true);
- result = PopUpMenuSelect (menu, corner.v, corner.h + 1, *choice);
- CheckItem (menu, *choice, false);
- DeleteMenu (menuID);
- if (HiWord (result) != 0) {
- if (LoWord (result) != *choice) {
- *choice = LoWord (result);
- InsetRect (&bounds, 1, 1);
- InvalRect (&bounds);
- }
- }
- }
- } /*TrackPopup*/
-
- /*----------*/
- Boolean TrackButton (button, mousePos)
- ControlHandle button;
- Point mousePos;
- {
- return (TrackControl (button, mousePos, nil) != 0);
- } /*TrackButton*/
-
- /*----------*/
- void TrackCheck (checkBox, mousePos, checked)
- ControlHandle checkBox;
- Point mousePos;
- Boolean *checked;
- {
- if (TrackControl (checkBox, mousePos, nil) != 0) {
- *checked = !*checked;
- SetCtlValue (checkBox, *checked);
- }
- } /*TrackCheck*/
-
- /*----------*/
- void TrackRadio (radio, mousePos, choice)
- ControlHandle radio;
- Point mousePos;
- short *choice;
- {
- long refCon;
- short group;
- ControlHandle control;
-
- if (TrackControl (radio, mousePos, nil) != 0) {
- refCon = GetCRefCon (radio);
- group = HiWord (refCon);
- *choice = LoWord (refCon);
- control = ((WindowPeek) thePort)->controlList;
- while (control != nil) {
- if ((**control).contrlDefProc == (**radio).contrlDefProc) {
- refCon = GetCRefCon (control);
- if (HiWord (refCon) == group) {
- SetCtlValue (control, 0);
- }
- }
- control = (**control).nextControl;
- } /*while*/
- SetCtlValue (radio, 1);
- }
- } /*TrackRadio*/
-
- /*----------*/
- void TrackPalette (palette, mousePos, choice)
- ControlHandle palette;
- Point mousePos;
- short *choice;
- {
- if (TrackControl (palette, mousePos, nil) != 0) {
- *choice = GetCtlValue (palette);
- }
- } /*TrackPalette*/
-
- /*----------*/
- void HiliteScroll (scroll, active)
- ControlHandle scroll;
- Boolean active;
- {
- if (scroll != nil) {
- if (active) {
- HiliteControl (scroll, 0);
- } else {
- HiliteControl (scroll, 255);
- }
- }
- } /*HiliteScroll*/
-